package share.wave.facebook;

import java.net.URLEncoder;

import org.waveprotocol.wave.model.id.WaveId;

import com.google.wave.api.*;
import com.google.wave.api.event.*;

@SuppressWarnings("serial")
public class Share_wave_facebookServlet extends AbstractRobot {

  @Override
  protected String getRobotName() {
    return "Share-Wave-to-Facebook";
  }

  @Override
  protected String getRobotAvatarUrl() {
    return "https://wave.google.com/wave/static/images/group.jpg";
  }

  @Override
  protected String getRobotProfilePageUrl() {
    return "http://code.google.com/p/share-wave-facebook";
  }

  @Override
  public void onWaveletSelfAdded(WaveletSelfAddedEvent event) {
	WaveId id = event.getWavelet().getWaveId();
	String topic = event.getWavelet().getTitle();
	// https://wave.google.com/wave/#restored:wave:googlewave.com!w%252BKPDAXIcI3
	String url = "http://wave.google.com/wave/#restored:wave:"+id.getDomain()+"!"+id.getId();
	String fburl = "http://www.facebook.com/sharer.php?u="+url;
	event.getWavelet().getRootBlip().appendMarkup("<a href=\""+fburl+"\">Dela på Facebook</a>");
  }
}